package com.cizzy.favorite.controller;

import com.cizzy.favorite.common.Result;
import com.cizzy.favorite.entity.Collect;
import com.cizzy.favorite.entity.Favorite;
import com.cizzy.favorite.entity.dto.VideoDTO;
import com.cizzy.favorite.entity.vo.CollectRequest;
import com.cizzy.favorite.entity.vo.FavoriteRequest;
import com.cizzy.favorite.service.ICollectService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import java.util.List;

import static com.cizzy.favorite.config.CizzyFinal.PAGE_SIZE;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author crissy-月下闲人
 * @since 2023-11-03
 */
@RestController
@RequestMapping("/collect")
public class CollectController {
    @Resource
    private ICollectService collectService;

    @ResponseBody
    @PostMapping("collect")
    public Result<Collect> createCollect(@RequestBody CollectRequest collectRequest) {
        return collectService.createCollect(collectRequest);
    }

    @ResponseBody
    @PostMapping("cancelCollect")
    public Result<Collect> cancelCollect(@RequestBody CollectRequest collectRequest) {
        return collectService.cancelCollect(collectRequest);
    }

    @ResponseBody
    @GetMapping("/isCollectd/{userId}/{videoId}")
    public Result<Boolean> isCollectd(@PathVariable("userId") Long userId, @PathVariable("videoId") Long videoId) {
        return collectService.isCollectd(userId, videoId);
    }

    @ResponseBody
    @GetMapping("/getCollectById/{userId}")
    public Result<List<VideoDTO>> getCollectById(@PathVariable("userId") Long userId) {
        return collectService.getCollectById(userId);
    }

    @ResponseBody
    @GetMapping("/getCollectPageById/{userId}/{page}")
    public Result<List<VideoDTO>> getCollectPageById(@PathVariable("userId") Long userId, @PathVariable("page") Integer page) {
        return collectService.getCollectPageById(userId, page, PAGE_SIZE);
    }

//    @GetMapping("toCollect/{id}")
//    public Result<String> toCollect(@PathVariable("id") Long id) {
//        return collectService.toCollect(id);
//    }
//
//    @PostMapping("getCollectList")
//    public Result<List<VideoDTO>> getCollectList() {
//        return collectService.getCollectList();
//    }
}
